import WebView from 'react-native-webview';
import { View, Text } from 'react-native';
import { TestCase, Tester, TestSuite } from '@rnoh/testerino';
import React from 'react';

export default function WebViewTestoriginWhitelist() {
  return (
    <View style={{ flex: 1, padding: 20 }}>
      <Tester style={{ paddingBottom: 80 }}>
        <TestSuite name="react-native-webview">
          {/* 测试1: 允许所有来源 */}
          <TestCase
            key={'originWhitelist-all'}
            itShould="originWhitelist={'*'} - 允许所有网站"
            tags={['C_API']}
            initialState={false}
            arrange={({ setState }) => {
              return (
                <View style={{ padding: 20 }}>
                  <Text style={{ fontSize: 16, fontWeight: 'bold', marginBottom: 10 }}>
                    测试1: originWhitelist={'*'}
                  </Text>
                  <Text style={{ marginBottom: 10, color: '#666' }}>
                    允许访问所有网站，无限制
                  </Text>
                  <View style={{ height: 250, borderWidth: 1, borderColor: '#ccc' }}>
                    <WebView
                      source={{ uri: "https://www.baidu.com" }}
                      originWhitelist={['*']}
                      style={{ flex: 1 }}
                    />
                  </View>
                  
                  <Text style={{ marginBottom: 10, color: '#666' }}>
                    只允许访问华为开发者网站，其他网站会被阻止
                  </Text>
                  <View style={{ height: 250, borderWidth: 1, borderColor: '#ccc' }}>
                    <WebView
                      source={{ uri: "https://www.baidu.com" }}
                      originWhitelist={['https://developer.huawei.co']}
                      style={{ flex: 1 }}
                    />
                  </View>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              expect(state).to.be.true;
            }}
          />

         
        
             
        </TestSuite>
      </Tester>
    </View>
  );
}
